package com.ghq.service.impl;

import com.ghq.mapper.DrugsMapper;
import com.ghq.pojo.Drugs;
import com.ghq.service.DrugsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrugsServiceImpl implements DrugsService {
    private final DrugsMapper drugsMapper;

    @Autowired
    public DrugsServiceImpl(DrugsMapper drugsMapper) {
        this.drugsMapper = drugsMapper;
    }

    @Override
    public List<Drugs> getAllDrugs() {
        return drugsMapper.selectAllDrugs();
    }

    @Override
    public void deleteDrug(Integer id) {
        drugsMapper.deleteDrug(id);
    }

    @Override
    public Drugs getDrugById(Integer id) {
        return drugsMapper.getDrugById(id);
    }

    @Override
    public void addDrug(Drugs drugs) {
        drugsMapper.insertDrug(drugs);
    }

    @Override
    public void updateDrug(Drugs drugs) {
        drugsMapper.updateDrug(drugs);
    }

    @Override
    public List<Drugs> getDrugByNameAndCategory(String name, String category) {
        return drugsMapper.getDrugByNameAndCategory(name,category);
    }

    @Override
    public void deleteDrugs(List<Integer> ids) {
        drugsMapper.deleteDrugs(ids);
    }
}
